package com.poem.mapper;

import com.github.pagehelper.Page;
import com.poem.annotation.AutoFill;
import com.poem.dto.PoemsPageQueryDTO;
import com.poem.entity.Poems;
import com.poem.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ClassName: PoemsMapper
 * @Author: YLY
 * @Description:
 * @Date: 2025/10/18
 * @Version: 1.0
 */
@Mapper
public interface PoemsMapper {

    /**
     * 查询所有古诗
     * 
     * @return
     */
    List<Poems> getAllPoems();

    /**
     * 添加古诗
     * 
     * @param poem
     */
    @AutoFill(value = OperationType.INSERT)
    void addPoem(Poems poem);

    /**
     * 修改古诗
     * 
     * @param poem
     */
    @AutoFill(value = OperationType.UPDATE)
    void updatePoem(Poems poem);

    /**
     * 删除古诗
     * 
     * @param ids
     */
    void deleteBatch(List<Long> ids);

    Page<Poems> pageQuery(PoemsPageQueryDTO poemsPageQueryDTO);

    /**
     * 根据id查询
     * 
     * @param id
     * @return
     */
    @Select("select * from poems where id = #{id}")
    Poems getById(Long id);

    Integer countByType(Long typeId);

    Integer countByAuthorId(Long authorId);

    List<Poems> getPoems(List<Long> ids);
}